<?php

if (!defined("IN_TRACKER"))  die("Hacking attempt!");
require_once($rootpath . 'include/init.php');
require_once($rootpath . 'include/api_cache.php');
require_once($rootpath . 'include/api_database.php');
require_once($rootpath . 'include/api_options.php');
require_once($rootpath . 'include/api_graphic.php');
require_once($rootpath . 'include/api_system.php');
require_once($rootpath . 'include/secrets.php');
require_once($rootpath . 'include/global.php');
require_once($rootpath . 'include/functions.php');
require_once($rootpath . 'include/blocks.php');
require_once($rootpath . 'include/torrent.php');


if ( !filesize('include/secrets.php') ) {
	header('Location: install/');
	die();
}

session_start();
dbconn();
LoadOptions();

if ( $options['last_cleanup'] < TIMENOW ) {
	SetOption('last_cleanup',TIMENOW+$options['autoclean_interval']);
	require_once('include/cleanup.php');
	@ignore_user_abort(1);
	set_time_limit(0);
	register_shutdown_function('docleanup');
}

if ( $options['default_language'] == 'russian' ) header('Content-Type: text/html; charset=windows-1251');
userlogin();

if ( !empty($options['debug']) ) {
    @ini_set('display_errors','On');
    @ini_set('error_reporting','E_ERROR & E_WARNING');
    if ( is_admin() && $options['profailer'] ) require_once('xhprof/head.php');
}

if (!isset($HTTP_POST_VARS) && isset($_POST)) {
	$HTTP_POST_VARS = $_POST;
	$HTTP_GET_VARS = $_GET;
	$HTTP_SERVER_VARS = $_SERVER;
	$HTTP_COOKIE_VARS = $_COOKIE;
	$HTTP_ENV_VARS = $_ENV;
	$HTTP_POST_FILES = $_FILES;
}

if (get_magic_quotes_gpc()) {
	if (!empty($_GET))    { $_GET    = strip_magic_quotes($_GET);    }
	if (!empty($_POST))   { $_POST   = strip_magic_quotes($_POST);   }
	if (!empty($_COOKIE)) { $_COOKIE = strip_magic_quotes($_COOKIE); }
}

if (!get_magic_quotes_gpc()) {
	if (is_array($HTTP_GET_VARS)) {
		while (list($k, $v) = each($HTTP_GET_VARS)) {
			if (is_array($HTTP_GET_VARS[$k])) {
				while (list($k2, $v2) = each($HTTP_GET_VARS[$k])) {
					$HTTP_GET_VARS[$k][$k2] = addslashes($v2);
				}
				@reset($HTTP_GET_VARS[$k]);
			} else {
				$HTTP_GET_VARS[$k] = addslashes($v);
			}
		}
		@reset($HTTP_GET_VARS);
	}

	if (is_array($HTTP_POST_VARS)) {
		while (list($k, $v) = each($HTTP_POST_VARS)) {
			if (is_array($HTTP_POST_VARS[$k])) {
				while (list($k2, $v2) = each($HTTP_POST_VARS[$k])) {
					$HTTP_POST_VARS[$k][$k2] = addslashes($v2);
				}
				@reset($HTTP_POST_VARS[$k]);
			} else {
				$HTTP_POST_VARS[$k] = addslashes($v);
			}
		}
		@reset($HTTP_POST_VARS);
	}

	if (is_array($HTTP_COOKIE_VARS)) {
		while (list($k, $v) = each($HTTP_COOKIE_VARS)) {
			if (is_array($HTTP_COOKIE_VARS[$k])) {
				while (list($k2, $v2) = each($HTTP_COOKIE_VARS[$k])) {
					$HTTP_COOKIE_VARS[$k][$k2] = addslashes($v2);
				}
				@reset($HTTP_COOKIE_VARS[$k]);
			} else {
				$HTTP_COOKIE_VARS[$k] = addslashes($v);
			}
		}
		@reset($HTTP_COOKIE_VARS);
	}
}
?>